<?php
// +----------------------------------------------------------------------
// | NewThink [ Think More,Think Better! ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2019 http://www.newthink.cc All rights reserved.
// +----------------------------------------------------------------------
// | 版权所有：山西创泰网络科技有限公司
// +----------------------------------------------------------------------

namespace app\api\controller;

use app\common\service\airquality\AirQualityRankingStatisticsService;
use app\common\validate\airQuality\AirQualityWeatherAnalysisValidate;

/**
 * 空气质量预报 - 排名统计
 */
class AirQualityRankingStatistics extends BaseController
{
    public function getAirQualityRankingStatisticsTable()
    {
        $param = $this->request->param();
        #模拟数据
//        $param    = ['look_time' => '2019-04',  'date_type'=>'month', 'region_id'=>'53', 'station_select'=>1];
//        $param    = ['look_time' => '2019',  'date_type'=>'year', 'region_id'=>'53','station_select'=>1];
//        $param    = ['look_time' => '2019-05-29',  'date_type'=>'day', 'region_id'=>'53', 'station_select'=>1];
        $validate = new AirQualityWeatherAnalysisValidate();
        $result   = $validate->check($param, [], 'airQualityRankingStatistics');
        if (!$result) {
            $this->error($validate->getError());
        }
        $list = [];
        try {
            $airQualityRankingStatisticsService = new AirQualityRankingStatisticsService();
            $list                               = $airQualityRankingStatisticsService->getTable($param);
        } catch (\Exception $e) {
            $this->error($e->getMessage());
        }
        $this->success('成功', $list);
    }
}